<?php
namespace DesignPatterns\Traits;

trait Singleton {
    /**
     * @var object 单例对象实例
     */
    private static  $instance;

    protected function __construct()
    {
    }

    public static function getInstance($config = [])
    {
        if (null === self::$instance) {
            self::$instance = new static($config);
        }
        return self::$instance;
    }

    protected function __clone()
    {
    }

    protected function __wakeup()
    {
    }
}